﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using SocialIn.Core.Data;
using System.Data;

namespace SocialIn.Biz
{
    public sealed class CommonData
    {
        ConnectionStringSettings _BaseDBCon = null;

        public CommonData()
        {
            _BaseDBCon = ConfigurationManager.ConnectionStrings[ConfigName.DBConfig];
        }

        public Result<DataTable> GetCodeMaster(string categoryCode)
        {
            Result<DataTable> resultValue = null;

            string query = String.Format(@"select *
from dbo.CodeMaster
where category = '{0}'
	and ApplyDate <= '{1}'
	and [ExpireDate] >= '{1}'
order by sort", categoryCode, DateTime.Now.ToString("yyyyMMdd"));

            //Dictionary<string, string> parameters = new Dictionary<string, string>();

            SqlHelper sql = new SqlHelper(_BaseDBCon.ProviderName, _BaseDBCon.ConnectionString);
            resultValue = sql.ExecuteDataTable(query, null);

            return resultValue;          
        }
    }
}
